package com.yourname.myapplication.ieportQuestions
import android.content.Context
import android.os.Environment
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.yourname.myapplication.data.model.Question
import java.io.File
import java.io.FileReader

fun importQuestions(context: Context): List<Question>? {
    val externalFilesDir = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
    val file = File(externalFilesDir, "questions.json")

    return try {
        val reader = FileReader(file)
        val type = object : TypeToken<List<Question>>() {}.type
        val gson = Gson()
        gson.fromJson(reader, type)
    } catch (e: Exception) {
        e.printStackTrace()
        null
    }
}